<#include "/common/_layout.html">
<#assign pageJavascript>
<script type="text/javascript">
var delit = function(obj){
	var tr = $(obj).parent().parent("tr").attr("id");
	var id = tr.replace("tr_","");
	listPage.deleteTr(tr,id);
};
var chgit = function(id,stat){
	$.post("/admin/user/chgstat",{id:id,stat:stat},function(data){
		if(data.msg=="success"){
		    layer.msg('修改成功!');
		    $("#querybtn").click();
		}
	    else{
		    layer.msg('修改失败!', {icon: 5});
	    }})
};
$(function(){
	listPage.config = {listUrl:"/admin/user/profile",delUrl:"/admin/user/del"};
	listPage.showlist = function(data){
		if(data.list == undefined) return false;
		$("#showlist").empty();
		$.each(data.list, function (i, row) {
			var stat = "class='success'>正常";
			var editbtn = '<button class="btn btn-warning btn-xs" onclick="chgit(\''+row.id+'\',0)">禁用</button>';
			if(row.stat==0){ 
				stat = "class='warning'>禁用";
				editbtn = '<button class="btn btn-success btn-xs" onclick="chgit(\''+row.id+'\',1)">启用</button>';
			}
			var str = '<tr id="tr_'+row.id+'"><td>'+row.username+'</td><td>'+null2blank(row.mobile)+'</td><td '+stat+'</td><td>'+row.intime+'</td><td>'
				+editbtn
				+'&nbsp;<a class="btn btn-default btn-xs" href="/admin/user/userdevice/'+row.id+'">设备列表</a>'
				+'&nbsp;<a class="btn btn-info btn-xs" href="/admin/user/userstatis/'+row.id+'">操作统计</a>'
				+'&nbsp;<button class="btn btn-danger btn-xs" onclick="delit(this)">删除</button>'
				+'</td></tr>';
			$("#showlist").append(str);
		});
		$("#page").page({total:data.totalRow,currentpage:data.pageNumber,gopage:listPage.gopage,pagesize:data.pageSize});
	};
	$("#querybtn").click(function(){
		listPage.gopage(10,1);
	});
	$("#querybtn").click();	
});
</script>
</#assign>
<#assign pageCss>
<style type="text/css">
</style>
</#assign>
<@layout pageTitle="用户管理" pageJavascript=pageJavascript pageCss=pageCss>		
<br/>
<h3 class="page-header">用户管理</h3>
<div class="panel panel-default">
  <div class="panel-body filter">
	<div class="form-inline">
		<div class="form-group">
			<label for="username">用户名</label> 
			<input type="text" class="form-control" id="username" data-rule="like">
			<label>注册时间</label>
		    <input class="form-control" style="width:120px" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd'})" type="input" data-rule="ge" id="start_t.intime" >～
			<input class="form-control" style="width:120px" onFocus="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd'})" type="input" data-rule="dtle" id="end_t.intime" >
		</div>
		<button id="querybtn" class="btn btn-default">查询</button>
	</div>
  </div>
</div>
<table class="table table-bordered table-hover table-striped">
	<thead>
		<tr>
			<th width="60px">用户名</th>
			<th width="60px">手机号</th>
			<th width="60px">状态</th>
			<th width="120px">注册时间</th>
			<th width="60px">操作</th>
		</tr>
	</thead>
	<tbody id="showlist"></tbody>
</table>
<nav><ul id="page" class="pagination"></ul></nav>
</@layout>